package com.neuedu.service.impl;

import com.neuedu.dao.UserDao;
import com.neuedu.dao.impl.UserDaoImpl;
import com.neuedu.model.User;
import com.neuedu.service.UserService;

import java.util.List;

public class UserServiceImpl implements UserService {
    private UserDao userDao=new UserDaoImpl();
    @Override
    public int updateUserIconById(Integer id, String icon) {
        User user=new User();
        user.setId(id);
        user.setIcon(icon);
        return userDao.updateUserByIdSelective(user);
    }

    @Override
    public int updateUserById(User user) {
        return userDao.updateUserByIdSelective(user);
    }

    @Override
    public User findUserById(Integer id) {

        return userDao.selectUser(id);
    }

    @Override
    public User findUserBySignInfo(String username, String password) {
        return userDao.selectUserByUnameAndPwd(username,password);
    }

    @Override
    public List<User> selectUserAll() {
        List<User> users = userDao.selectAll();
        for (int i = 0; i < users.size(); i++) {
            users.get(i).setPassword("");
        }
        return users;
    }
}
